import os, shutil
import cPickle as pickle


_game_path = 'wormbane-game.save'
_level_path = 'wormbane-level-%d.save'


def save_game(game):
    file = open(_game_path, 'wb')
    pickle.dump(game, file, pickle.HIGHEST_PROTOCOL)


def load_game():
    file = open(_game_path, 'rb')
    return pickle.load(file)


def remove_save_file():
    os.remove(_game_path)


def save_level(level):
    file = open(_level_path % level.num, 'wb')
    pickle.dump(level, file, pickle.HIGHEST_PROTOCOL)


def load_level(level_num):
    file = open(_level_path % level_num, 'rb')
    return pickle.load(file)
